﻿using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.SideChannels;
using System;
using System.Collections.Generic;

public class EnvironmentStateChannel : SideChannel
{
    private EnvironmentController envCtrler;
    public EnvironmentStateChannel(EnvironmentController envCtrler)
    {
        this.envCtrler = envCtrler;
        ChannelId = new Guid("621f0a70-4f87-11ea-a6bf-784f4387d1f9");
    }

    protected override void OnMessageReceived(IncomingMessage msg)
    {
        Debug.LogError("The EnvironmentStateChannel received a message from Python, "
            + "this should not have happend.");
    }

    public void SendStateMessage()
    {
        OutgoingMessage msg = new OutgoingMessage();
        msg.WriteBoolean(envCtrler.GetDone());
        QueueMessageToSend(msg);
        /*
        foreach(PlaygroundController pgc in envCtrler.plygrndCtrlers)
        {
            FlightAgent[] flightAgents = pgc.GetComponentsInParent<FlightAgent>();

        }*/
    }
    
}